package com.xinshujia.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xinshujia.entity.DeviceEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * *************************************
 * *   @author: 野狼上校               **
 * *   @since: 2024-07-19 17:35       **
 * *   @version: 1.0                  **
 * *************************************
 * <p>
 * 设备数据持久化
 */
@Mapper
public interface DeviceDao extends BaseMapper<DeviceEntity> {
    /**
     * 根据设备Guid查询设备
     */
    @Select("SELECT * FROM blade_device WHERE device_guid = #{deviceGuid};")
    DeviceEntity findDeviceByDeviceGuid(@Param("deviceGuid") String deviceGuid);

    /**
     * 更新设备预警状态
     */
    @Update("UPDATE blade_device SET alarm_status = #{operateType} WHERE device_guid = #{deviceGuid};")
    void updateDeviceAlarmStatus(@Param("deviceGuid") String deviceGuid, @Param("operateType") int operateType);
}
